<template>
  <div>
    <!-- 头部 -->
    <div class="header">
      <div class="header-content">
        <div @click="goback()">
          <img src="yangchaung//images/图片 (1).png" class="back-up" />
        </div>
        <div class="pet-logo">宠物</div>
        <div class="input-content">
          <img
            src="https://p0.meituan.net/travelcube/99c29829cf1b85d5cdbc76a1bd0b7329814.png"
            alt
            class="search-logo"
            width="20vw"
            height="15vw"
          />
          <span>搜索商户名/服务项目</span>
        </div>
        <input type="text" placeholder class="pet-ipt" />
        <div class="pet-health">
          <img src="yangchaung/images/图片 (3).png" alt width="25vw" height="25vh" />
        </div>
      </div>
    </div>
    <!-- 下面是导航分类到轮播图 -->
    <div class="nav">
      <div class="content">
        <!-- 导航分类 -->
        <ul class="content-list">
          <li v-for="(item,index) in arr" :key="index">
            <img :src="item.img" alt width="50vw" height="50vh" />
            <p>{{item.name}}</p>
          </li>
        </ul>
        <!-- 热卖，优惠，甄选 -->
        <div class="hot-sale">
          <ul>
            <li v-for="(item,index) in hotsale" :key="index">
              <h3>{{item.title}}</h3>
              <p>{{item.content}}</p>
              <img :src="item.img" alt />
            </li>
          </ul>
        </div>
        <!-- 轮播图 -->
        <van-swipe class="my-swipe" :autoplay="4000" indicator-color="white">
          <van-swipe-item v-for="(v,i) in homeBanner" :key="i" class="content">
            <img class="img" :src="v.img" />
          </van-swipe-item>
        </van-swipe>
      </div>
      <!-- 上边是导航分类到轮播图框架里面的内容 -->
      <!-- 下面为你推荐和萌宠好去处 -->
    </div>
    <div class="warpc">
      <div class="warpcdh">
        <div class="foodlist">
          <router-link to="/petpage/ShopListE01">
            <p>为你推荐</p>
          </router-link>
          <router-link to="/petpage/ShopListE02" @click="fun()">
            <p>萌宠好去处</p>
          </router-link>
        </div>
      </div>
    </div>
    <router-view></router-view>
  </div>
</template>


<style lang="scss" scoped>
.back-up {
  width: 4.267vw;
  height: 6.667vw;
}
.my-swipe {
  margin-top: 0.5vh;
  height: 10vh;
  .img {
    width: 93.779vw;
    height: 19.2vw;
  }
}
.hot-sale {
  width: 93.779vw;
  height: 19.467vw;
  ul {
    display: flex;
    justify-content: space-between;
    li {
      background: #fff;
      width: 29.341vw;
      height: 15.467vw;
      border-radius: 1.6vw;
      border: 0.267vw solid #eee;
      position: relative;
      h3 {
        font-size: 3.84vw;
        margin-top: 0.8vw;
        margin-left: 1.067vw;
      }
      p {
        font-size: 3.413vw;
        margin-left: 1.067vw;
      }
      img {
        width: 7.428vw;
        position: absolute;
        right: 1.65vw;
        bottom: 0;
      }
    }
  }
}

body {
  background: #eee;
}

//头部
.header {
  width: 100vw;
  height: 4.497vh;
  position: relative;
  position: fixed;
  left: 0;
  top: 0;
  background: #fff;
  //头部的版心
  .header-content {
    width: 93.779vw;
    height: 3.748vh;
    display: flex;
    margin: auto;
    line-height: 3.748vh;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    //宠物这两个字
    .pet-logo {
      font-weight: bolder;
      font-size: 5.867vw;
    }
    .pet-ipt {
      margin-left: 3.993vw;
      width: 61.467vw;
      border-radius: 3.714vw;
      outline: none;
      background: none;
    }
    .pet-ipt::-webkit-input-placeholder {
      text-align: center;
    }
    .pet-health {
      margin-left: 3.528vw;
      margin-top: 0.533vw;
    }
    .input-content {
      width: 40.576vw;
      position: absolute;
      left: 29.028vw;
      top: 0.533vw;
      color: #999;
      font-size: 3.5vw;
      height: 2.998vh;
      line-height: 2.998vh;
      align-items: center;
      span {
        display: block;
        float: left;
        font-size: 0.467vw;
      }
      img {
        float: left;
        margin-top: 0.8vw;
      }
    }
  }
}
//导航分类
.nav {
  width: 100vw;
  height: 100.8vw;
  // background: green;
  margin-top: 10.667vw;
  .content {
    height: 100.8vw;
    // background: blue;
    .content-list {
      display: flex;
      width: 93.779vw;
      justify-content: space-between;
      flex-wrap: wrap;
      li {
        width: 20%;
        text-align: center;
        margin-bottom: 2.667vw;
        font-size: 1.3vw;
      }
    }
  }
}

* {
  margin: 0;
  padding: 0;
}
li {
  list-style: none;
}
.content {
  width: 93.779vw;
  margin: auto;
}

.van-tabs {
  width: 56.533vw;
}
.van-tabs__line {
  bottom: 6.4vw;
  width: 15.5vw !important ;
}

.warpc {
  margin-top: 5.6vw;
  .warpcdh {
    margin-top: 0.75rem;
    width: 100%;
    .foodlist {
      display: flex;
      width: 95%;
      margin: auto;
      justify-content: space-around;
      position: relative;
      a {
        display: flex;
        flex-direction: row;
        img {
          width: 1rem;
          line-height: 3.733vw;
          vertical-align: middle;
        }
        p {
          color: black;
          font-size: 3.2vw;
          font-weight: bold;
          padding-left: 1.333vw;

          line-height: 3.733vw;
        }
      }

      .line {
        width: 16vw;
        height: 2.133vw;
        background-image: linear-gradient(to right, #ed3828, #edac69);
        left: 7.4vw;
        bottom: -0.333vw;
        position: absolute;
        z-index: -99;
      }
    }
    .select {
      padding: 3.467vw 0;
      display: flex;
      width: 95%;
      margin: auto;
      justify-content: space-around;
      font-size: 3.2vw;
      span {
        padding: 0 1.333vw;
        margin-left: 1.333vw;
      }
      img {
        width: 2.133vw;
        vertical-align: middle;
      }
    }
  }
}
</style>

<script>
import axios from "axios";

import ShopList from "@/components/yangchaung/home/ShopList.vue";

export default {
  components: {
    ShopList
  },
  data() {
    return {
      arr: [],
      hotsale: [],
      homeBanner: [],
      recommend: ["为你推荐", "萌宠好去处"]
    };
  },
  methods: {
    goback() {
      this.$router.go(-1);
    }
  },
  created() {
    axios.request("http://localhost:8889/navlist").then(({ data }) => {
      this.arr = data;
    }),
      axios.request("http://localhost:8889/hotsale").then(({ data }) => {
        this.hotsale = data;
      }),
      axios.request("http://localhost:8889/homeBanner").then(({ data }) => {
        this.homeBanner = data;
      });
  }
};
</script>
